/*
 * PositionManager.h
 *
 *  Created on: Mar 11, 2010
 *      Author: dcrown
 */

#ifndef POSITIONMANAGER_H_
#define POSITIONMANAGER_H_

#include "Clock.h"
#include "MovePattern.h"

class PositionManager
{
public:
	enum BoundsRelation {INSIDE, OUTSIDE, STRADDLING};

	PositionManager() {}
	virtual ~PositionManager() {Clear();}

	void Clear();
	void Create(MovePattern* mp, int widthOffset = -1, int heightOffset = -1);
	void Create(int x, int y, MovePattern* mp = NULL, int widthOffset = -1, int heightOffset = -1);
	void Destroy();

	void Start();
	void Update();
	//void RandomChangeBearing(int spread);

	void SetAllPositions(float x, float y);

	float GetExactX() {return centerX;}
	float GetExactY() {return centerY;}
	int   GetCenterX() {return (int)centerX;}
	int   GetCenterY() {return (int)centerY;}
	int   GetOffsetX() {return offsetX;}
	int   GetOffsetY() {return offsetY;}

private:

	bool OffsetDimsValid();

	void SetOffsetPos();
	void SetCenterPos(float x, float y);
	void SetBearingStartPos();
	void StepMovePattern();

	MovePattern* mp;

	float centerX, centerY;
	int offsetX, offsetY;
	float bearingStartX, bearingStartY;
	int widthOffset, heightOffset;

	float currSpeed_ups;
	unsigned short currBearing_deg;
	int changeTime;
	int movePatternPos;

	bool running;

	Clock moveClock;
};

#endif /* POSITIONMANAGER_H_ */
